package com.heima.behavior.controller.v1;

import com.heima.behavior.service.UserLikeBehaviorService;
import com.heima.model.behavoir.dtos.LikesBehaviorDto;
import com.heima.model.behavoir.dtos.ReadBehaviorDto;
import com.heima.model.behavoir.dtos.UnLikesBehaviorDto;
import com.heima.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1")
public class UserLikeBehaviorController {

    @Autowired
    private UserLikeBehaviorService userLikeBehaviorService;

    /**
     * 用户点赞行为
     *
     * @param dto 文章id  操作方式
     * @return 返回结果
     */
    @PostMapping("/likes_behavior")
    public ResponseResult likesBehavior(@RequestBody LikesBehaviorDto dto) {
        return userLikeBehaviorService.likesBehavior(dto);
    }

    /**
     * 文章阅读信息增加
     *
     * @param dto 文章阅读数据
     * @return 返回结果
     */
    @PostMapping("/read_behavior")
    public ResponseResult readBehavior(@RequestBody ReadBehaviorDto dto) {
        return userLikeBehaviorService.readBehavior(dto);
    }


    /**
     * 文章不喜欢/取消不喜欢
     *
     * @param dto 文章id 操作方式
     * @return 返回结果
     */
    @PostMapping("/un_likes_behavior")
    public ResponseResult unLike(@RequestBody UnLikesBehaviorDto dto) {
        return userLikeBehaviorService.unLike(dto);
    }
}






















